package com.smart.web.controller.system;

import com.smart.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smart.common.annotation.Log;
import com.smart.common.core.controller.BaseController;
import com.smart.common.core.domain.AjaxResult;
import com.smart.common.enums.BusinessType;
import com.smart.system.domain.AbnormalOperation;
import com.smart.system.service.IAbnormalOperationService;
import com.smart.common.utils.poi.ExcelUtil;
import com.smart.common.core.page.TableDataInfo;

/**
 * 异常作业Controller
 * 
 * @author smart
 * @date 2024-09-18
 */
@RestController
@RequestMapping("/system/operation")
@Api(tags = "异常作业")
public class AbnormalOperationController extends BaseController
{
    @Autowired
    private IAbnormalOperationService abnormalOperationService;

    /**
     * 查询异常作业列表
     */
    @ApiOperation(value = "查询异常作业列表")
    //@PreAuthorize("@ss.hasPermi('system:operation:list')")
    @GetMapping("/list")
    public TableDataInfo<AbnormalOperation> list(AbnormalOperation abnormalOperation)
    {
        startPage();
        List<AbnormalOperation> list = abnormalOperationService.selectAbnormalOperationList(abnormalOperation);
        return getDataTable(list);
    }

    /**
     * 导出异常作业列表
     */
    @ApiOperation(value = "导出异常作业列表")
    //@PreAuthorize("@ss.hasPermi('system:operation:export')")
    @Log(title = "异常作业", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AbnormalOperation abnormalOperation)
    {
        List<AbnormalOperation> list = abnormalOperationService.selectAbnormalOperationList(abnormalOperation);
        ExcelUtil<AbnormalOperation> util = new ExcelUtil<AbnormalOperation>(AbnormalOperation.class);
        util.exportExcel(response, list, "异常作业数据");
    }

    /**
     * 获取异常作业详细信息
     */
    @ApiOperation(value = "获取异常作业详细信息")
    //@PreAuthorize("@ss.hasPermi('system:operation:query')")
    @GetMapping(value = "/{id}")
    public R<AbnormalOperation> getInfo(@PathVariable("id") String id)
    {
        return R.ok(abnormalOperationService.selectAbnormalOperationById(id));
    }

    /**
     * 新增异常作业
     */
    @ApiOperation(value = "新增异常作业")
    //@PreAuthorize("@ss.hasPermi('system:operation:add')")
    @Log(title = "异常作业", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Integer> add(@RequestBody AbnormalOperation abnormalOperation)
    {
        return R.ok(abnormalOperationService.insertAbnormalOperation(abnormalOperation));
    }

    /**
     * 修改异常作业
     */
    @ApiOperation(value = "修改异常作业")
    //@PreAuthorize("@ss.hasPermi('system:operation:edit')")
    @Log(title = "异常作业", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Integer> edit(@RequestBody AbnormalOperation abnormalOperation)
    {
        return R.ok(abnormalOperationService.updateAbnormalOperation(abnormalOperation));
    }

    /**
     * 删除异常作业
     */
    @ApiOperation(value = "删除异常作业")
    //@PreAuthorize("@ss.hasPermi('system:operation:remove')")
    @Log(title = "异常作业", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R<Integer> remove(@PathVariable String[] ids)
    {
        return R.ok(abnormalOperationService.deleteAbnormalOperationByIds(ids));
    }
}
